package org.jeik.data.models;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

import org.jeik.common.CustomerRequestStatus;
import org.jeik.common.ServiceType;
import org.jeik.data.services.ServiceBase.Tables;
import org.joda.time.DateTime;
import org.joda.time.Months;

@SuppressWarnings("serial")
public class CustomerRequest implements Model {

	
	private Long id;
	private String firstName;
	private String lastName;
	private String identificationNumber;
	private String mobileNumber;
	private Long serviceType;
	private Long status;
	private String notes;
	private Date createdDate;
	private Date lastUpdatedDate;
	private Date applyDate;
	
	@Override
	public String getTableName() {
		// TODO Auto-generated method stub
		return Tables.requests.name();
	}

	@Override
	public List<String> getFields() {
		// TODO Auto-generated method stub
		return null;
	}

	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public String getMobileNumber() {
		return mobileNumber;
	}

	public void setMobileNumber(String mobileNumber) {
		this.mobileNumber = mobileNumber;
	}

	public Long getServiceType() {
		return serviceType;
	}

	public void setServiceType(Long serviceType) {
		this.serviceType = serviceType;
	}

	public Long getStatus() {
		return status;
	}

	public void setStatus(Long status) {
		this.status = status;
	}

	public Date getCreatedDate() {
		return createdDate;
	}

	public void setCreatedDate(Date createdDate) {
		this.createdDate = createdDate;
	}
	
	public String getFirstName() {
		return firstName;
	}

	public void setFirstName(String firstName) {
		this.firstName = firstName;
	}

	public String getLastName() {
		return lastName;
	}

	public void setLastName(String lastName) {
		this.lastName = lastName;
	}

	public String getIdentificationNumber() {
		return identificationNumber;
	}

	public void setIdentificationNumber(String identificationNumber) {
		this.identificationNumber = identificationNumber;
	}

	public String getNotes() {
		return notes;
	}

	public void setNotes(String notes) {
		this.notes = notes;
	}

	public Date getLastUpdatedDate() {
		return lastUpdatedDate;
	}

	public void setLastUpdatedDate(Date lastUpdatedDate) {
		this.lastUpdatedDate = lastUpdatedDate;
	}
	
	public Date getApplyDate() {
		return applyDate;
	}

	public void setApplyDate(Date applyDate) {
		this.applyDate = applyDate;
	}

	public String getServiceTypeDescription(Integer value){
		
		String result;
		switch(value){
		case 1: result = ServiceType.get(ServiceType.PASSPORT.name()).getLabel(); break;
		case 2: result = ServiceType.get(ServiceType.FAMILY_BOOKLET.name()).getLabel(); break;
		case 3: result = ServiceType.get(ServiceType.IDENTITY_CARD.name()).getLabel(); break;
		case 4: result = ServiceType.get(ServiceType.VISA.name()).getLabel(); break;
		case 5: result = ServiceType.get(ServiceType.NATIONAL_NUMBER.name()).getLabel(); break;
		case 6: result = ServiceType.get(ServiceType.GOOD_BEHAVIOR.name()).getLabel(); break;
		default : result = null;
		}
		
		return result;
	}
	
public String getStatusDescription(Integer value){
		
		String result;
		switch(value){
		case 1: result = CustomerRequestStatus.get(CustomerRequestStatus.PENDING.name()).getLabel(); break;
		case 2:  result = CustomerRequestStatus.get(CustomerRequestStatus.APPROVED.name()).getLabel(); break;
		case 3:  result = CustomerRequestStatus.get(CustomerRequestStatus.REJECTED.name()).getLabel(); break;
		case 4:  result = CustomerRequestStatus.get(CustomerRequestStatus.FOR_REVISION.name()).getLabel(); break;
		case 5:  result = CustomerRequestStatus.get(CustomerRequestStatus.DONE.name()).getLabel(); break;
		default : result = null;
		}
		
		return result;
	}

public String getFormattedDate(Date date){
	SimpleDateFormat formatter = new SimpleDateFormat("dd-MM-yyyy");
	String formattedDate = formatter.format(date);
	return formattedDate;
}

public Boolean getOldRecord(){

	DateTime customerApplyDate =  new DateTime(getApplyDate());
	if(Math.abs(Months.monthsBetween(customerApplyDate, new DateTime(new Date())).getMonths()) > 6 ){
		return true;
	}
	
	return false;
}

}
